import request from '@/utils/request'
/**
 * 生成订单
 * @param {*} id 
 * @returns 
 */
export const createOrder  = (id) => {
    return request('/member/order/pre', 'get')
}
/**
 * 添加收货地址
 * @param {*} address 地址对象2
 * @returns 
 */
export const addAddress  = (address) => {
    return request('/member/address', 'post',address)
}
/**
 * 更新地址
 * @param {*} address 地址对象
 * @returns 
 */
export const updataAddress  = (address) => {
    console.log(address.id);
    return request(`/member/address/${address.id}`, 'put',address)
}
/**
 * 提交订单 购物车购买
 * @param {*} data 
 * @returns 
 */
export const placeOrder  = (data) => {
    return request('/member/order', 'post',data)
}
/**
 * 再次购买
 * @param {*} orderId 
 * @returns 
 */
export const buyAgain  = (orderId) => {
    return request(`/member/order/repurchase/${orderId}`, 'get')
}
/**
 * 获取我的订单详情
 * @param {*} id 
 * @returns 
 */
export const   orderDetails= (id) => {
    console.log(id);
    return request(`/member/order/${id}`, 'get')
}
/**
 * 获取我的订单
 * @param {*} pageSize
 * @param {*} page
 * @param {*} orderState
 * @returns 
 */
export const myOrders=({page=1,pageSize=10,orderState=0})=>{
    return request('/member/order','get',{page,pageSize,orderState})
}
/**
 * 取消订单
 * @param {*} id 商品id
 * @param {*} cancelReason  取消订单理由
 * @returns 
 */
export const cancelOrder=(id,cancelReason)=>{
    return request(`/member/order/${id}/cancel`,'put',{cancelReason})
}
/**
 * 删除订单
 * @param {*} id 订单id
 * @returns 
 */
export const DeleteOrderApi=(id)=>{
    return request(`/member/order`,'delete',{ids:[id]})
}
/**
 * 确定收货
 * @param {*} id 商品id
 * @returns 
 */
export const ConfirmGoodsApi=(id)=>{
    return request(`/member/order/${id}/receipt`,'put')
}
/**
 * 物流信息
 * @param {*} id 商品id
 * @returns 
 */
export const LogisticsInformationApi=(id)=>{
    return request(`/member/order/${id}/logistics`,'get')
}
